/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package org.fh.itsbankomat.businesslogic.model;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author MeinLaptop
 */
@Entity
@Table(name = "KUNDE")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Kunde.findAll", query = "SELECT k FROM Kunde k"),
    @NamedQuery(name = "Kunde.findByKundeid", query = "SELECT k FROM Kunde k WHERE k.kundeid = :kundeid"),
    @NamedQuery(name = "Kunde.findByVorname", query = "SELECT k FROM Kunde k WHERE k.vorname = :vorname"),
    @NamedQuery(name = "Kunde.findByZuname", query = "SELECT k FROM Kunde k WHERE k.zuname = :zuname"),
    @NamedQuery(name = "Kunde.findByGeburtsdatum", query = "SELECT k FROM Kunde k WHERE k.geburtsdatum = :geburtsdatum"),
    @NamedQuery(name = "Kunde.findByPlz", query = "SELECT k FROM Kunde k WHERE k.plz = :plz"),
    @NamedQuery(name = "Kunde.findByStrasse", query = "SELECT k FROM Kunde k WHERE k.strasse = :strasse"),
    @NamedQuery(name = "Kunde.findByOrt", query = "SELECT k FROM Kunde k WHERE k.ort = :ort")})
public class Kunde implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "KUNDEID")
    private Integer kundeid;
    @Size(max = 30)
    @Column(name = "VORNAME")
    private String vorname;
    @Size(max = 30)
    @Column(name = "ZUNAME")
    private String zuname;
    @Column(name = "GEBURTSDATUM")
    @Temporal(TemporalType.DATE)
    private Date geburtsdatum;
    @Size(max = 5)
    @Column(name = "PLZ")
    private String plz;
    @Size(max = 40)
    @Column(name = "STRASSE")
    private String strasse;
    @Size(max = 30)
    @Column(name = "ORT")
    private String ort;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "kunde")
    private Collection<Konto> kontoCollection;

    public Kunde() {
    }

    public Kunde(Integer kundeid) {
        this.kundeid = kundeid;
    }

    public Integer getKundeid() {
        return kundeid;
    }

    public void setKundeid(Integer kundeid) {
        this.kundeid = kundeid;
    }

    public String getVorname() {
        return vorname;
    }

    public void setVorname(String vorname) {
        this.vorname = vorname;
    }

    public String getZuname() {
        return zuname;
    }

    public void setZuname(String zuname) {
        this.zuname = zuname;
    }

    public Date getGeburtsdatum() {
        return geburtsdatum;
    }

    public void setGeburtsdatum(Date geburtsdatum) {
        this.geburtsdatum = geburtsdatum;
    }

    public String getPlz() {
        return plz;
    }

    public void setPlz(String plz) {
        this.plz = plz;
    }

    public String getStrasse() {
        return strasse;
    }

    public void setStrasse(String strasse) {
        this.strasse = strasse;
    }

    public String getOrt() {
        return ort;
    }

    public void setOrt(String ort) {
        this.ort = ort;
    }

    @XmlTransient
    public Collection<Konto> getKontoCollection() {
        return kontoCollection;
    }

    public void setKontoCollection(Collection<Konto> kontoCollection) {
        this.kontoCollection = kontoCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (kundeid != null ? kundeid.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Kunde)) {
            return false;
        }
        Kunde other = (Kunde) object;
        if ((this.kundeid == null && other.kundeid != null) || (this.kundeid != null && !this.kundeid.equals(other.kundeid))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.fh.itsbankomat.businesslogic.model.Kunde[ kundeid=" + kundeid + " ]";
    }
    
}
